package sz.szsmk.citizencard.ui.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chenenyu.router.annotation.Route;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.PsdAdminActivityBinding;
import sz.szsmk.citizencard.ioc.Compontent.DaggerCommonActivityComponent;
import sz.szsmk.citizencard.model.network.bean.response.GestureValidBean;
import sz.szsmk.citizencard.mvp.contract.IPasAdminContact;
import sz.szsmk.citizencard.mvp.presenter.PsdAdminPresenter;
import sz.szsmk.citizencard.ui.base.IBaseActivity;
import sz.szsmk.citizencard.util.JumpUtils;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/7/10 10:47
 * description:
 */
@Route("psdadmin")
public class PsdAdminActivity extends IBaseActivity<PsdAdminPresenter, PsdAdminActivityBinding>
        implements IPasAdminContact.IPsdAdminView, View.OnClickListener {
    ImageView back;
    TextView settingTitle;
    RelativeLayout psdadminResetLogin;
    private String status= "";
    private TextView setTile;

    @Override
    protected int attachLayoutRes() {
        return R.layout.psd_admin_activity;
    }

    @Override
    protected void initInjector() {
        DaggerCommonActivityComponent.builder().appCompontent(DaggerApplication.getAppComponent())
                .build().inject(this);
    }

    @Override
    protected void initViews() {
//        settingTitle.setText("密码管理");
        setTile = (TextView) findViewById(R.id.setting_title);
        setTile.setText("密码管理");
//        dataBinding.setCache.setOnClickListener(this);

    }

    @Override
    protected void updateViews() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        back = findViewById(R.id.back);
        back.setOnClickListener(this);
        settingTitle =  findViewById(R.id.setting_title);
        settingTitle.setOnClickListener(this);
        psdadminResetLogin =  findViewById(R.id.psdadmin_reset_login);
        findViewById(R.id.set_gespsd).setOnClickListener(this);

    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.getGestureIsOpen();
    }

    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.back) {
            finish();
        } else if (id == R.id.psdadmin_reset_login) {
            Bundle bundle = new Bundle();
            bundle.putString("type", "reset");
            JumpUtils.jumptoNatvie(this, "setpsd", 0, bundle);
        } else if (id == R.id.set_gespsd) {
            String statusTv = dataBinding.setCache.getText().toString().trim();
            if (statusTv.equals("已开通")) {
                JumpUtils.jump(this, "GesPsdActivity", 0);

            } else {
                JumpUtils.jump(this, "gesPasswordSettingActivity", 0);
//                    Toast.makeText(this, "未开通条状", Toast.LENGTH_SHORT).show();
            }
            //            case R.id.psdadmin_reset_pay:
//
//                break;
        }
    }

    @Override
    public void getGestureIsOpenSucc(GestureValidBean response) {
        status = response.getIsOpen();
        //0.不存在 1.存在已开启 2.存在未开启
        if (status.equals("1") || status.equals("2")) {
            dataBinding.setCache.setText("已开通");
        } else {
            dataBinding.setCache.setText("未开通");
        }
    }

    @Override
    public void getGestureIsOpenFail(GestureValidBean response) {

    }

    @Override
    public void onClick(View v) {
        onViewClicked(v);
    }

//    @Override
//    public void onClick(View v) {
//        switch (v.getId()) {
//            case R.id.set_cache:
//                String statusTv = dataBinding.setCache.getText().toString().trim();
//                if (statusTv.equals("已开通")) {
//                    JumpUtils.jump(this,"GesPsdActivity",0);
//
//                } else {
//                    JumpUtils.jump(this,"GesPasswordSettingActivity",0);
////                    Toast.makeText(this, "未开通条状", Toast.LENGTH_SHORT).show();
//                }
//                break;
//        }
//    }
}
